<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>解决Promise状态保护及异常捕获</title>
  <script src="./promise.js"></script>
</head>
<body>
  <ul>
    <li>只有状态是pending才改变Promise的状态为resolved或rejected，一旦改变状态就固定</li>
    <li>当Promise内部出现异常(使用未定义变量，throw异常等)，将由reject来承接错误</li>
    <li>Promise构造函数定义完毕，接下来开始定义then函数部分(未解决)</li>
  </ul>
  <script>
    const promise = new MyPromise((resolve, reject) => {
      console.log(a)
      resolve('success')
      reject('fail')
    })
    console.log(promise)
  </script>
</body>
</html>